package com.hospital.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hospital.domain.pojo.Hospitalization;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface HospitalizationMapper extends BaseMapper<Hospitalization> {
    
    @Select("SELECT * FROM hospitalization WHERE pId = #{pId} ORDER BY hAdmissionTime DESC")
    List<Hospitalization> selectByPatient(Integer pId);
    
    @Select("SELECT * FROM hospitalization WHERE dId = #{dId} AND hState = #{state}")
    List<Hospitalization> selectByDoctorAndState(Integer dId, Integer state);
    
    @Select("SELECT * FROM hospitalization WHERE depId = #{depId} AND hState = #{state}")
    List<Hospitalization> selectByDepartmentAndState(Integer depId, Integer state);
    
    @Select("SELECT * FROM hospitalization WHERE hState = #{state}")
    List<Hospitalization> selectByState(Integer state);
}
